<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The GearmanWorker class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gearmantask.uuid.html">GearmanTask::uuid</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="gearmanworker.addfunction.html">GearmanWorker::addFunction</a></div>
 <div class="up"><a href="book.gearman.html">Gearman</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.gearmanworker" class="reference">

 <h1 class="title">The GearmanWorker class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL gearman &gt;= 0.5.0)</p>


  <div class="section" id="gearmanworker.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    
   </p>
  </div>


  <div class="section" id="gearmanworker.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">GearmanWorker</strong>
     </span>
     {</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.addfunction.html" class="methodname">addFunction</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$function_name</code></span>
   , <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$function</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter reference">&$context</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$timeout</code></span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.addoptions.html" class="methodname">addOptions</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$option</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.addserver.html" class="methodname">addServer</a></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code><span class="initializer"> = 127.0.0.1</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = 4730</span></span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.addservers.html" class="methodname">addServers</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$servers</code><span class="initializer"> = 127.0.0.1:4730</span></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="gearmanworker.clone.html" class="methodname">clone</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="gearmanworker.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.echo.html" class="methodname">echo</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$workload</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span><span class="methodname"><a href="gearmanworker.error.html" class="methodname">error</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="gearmanworker.geterrno.html" class="methodname">getErrno</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="gearmanworker.options.html" class="methodname">options</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.register.html" class="methodname">register</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$function_name</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$timeout</code></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.removeoptions.html" class="methodname">removeOptions</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$option</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="gearmanworker.returncode.html" class="methodname">returnCode</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="function.func-name.html" class="methodname">setId</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$id</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.setoptions.html" class="methodname">setOptions</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$option</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.settimeout.html" class="methodname">setTimeout</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$timeout</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="gearmanworker.timeout.html" class="methodname">timeout</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.unregister.html" class="methodname">unregister</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$function_name</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.unregisterall.html" class="methodname">unregisterAll</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.wait.html" class="methodname">wait</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="gearmanworker.work.html" class="methodname">work</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>


  </div>

 </div>

 




















































































































































<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="gearmanworker.addfunction.html">GearmanWorker::addFunction</a> — Register and add callback function</li><li><a href="gearmanworker.addoptions.html">GearmanWorker::addOptions</a> — Add worker options</li><li><a href="gearmanworker.addserver.html">GearmanWorker::addServer</a> — Add a job server</li><li><a href="gearmanworker.addservers.html">GearmanWorker::addServers</a> — Add job servers</li><li><a href="gearmanworker.clone.html">GearmanWorker::clone</a> — Create a copy of the worker</li><li><a href="gearmanworker.construct.html">GearmanWorker::__construct</a> — Create a GearmanWorker instance</li><li><a href="gearmanworker.echo.html">GearmanWorker::echo</a> — Test job server response</li><li><a href="gearmanworker.error.html">GearmanWorker::error</a> — Get the last error encountered</li><li><a href="gearmanworker.geterrno.html">GearmanWorker::getErrno</a> — Get errno</li><li><a href="gearmanworker.options.html">GearmanWorker::options</a> — Get worker options</li><li><a href="gearmanworker.register.html">GearmanWorker::register</a> — Register a function with the job server</li><li><a href="gearmanworker.removeoptions.html">GearmanWorker::removeOptions</a> — Remove worker options</li><li><a href="gearmanworker.returncode.html">GearmanWorker::returnCode</a> — Get last Gearman return code</li><li><a href="function.func-name.html">GearmanWorker::setId</a> — Give the worker an identifier so it can be tracked when asking gearmand for the list of available workers.</li><li><a href="gearmanworker.setoptions.html">GearmanWorker::setOptions</a> — Set worker options</li><li><a href="gearmanworker.settimeout.html">GearmanWorker::setTimeout</a> — Set socket I/O activity timeout</li><li><a href="gearmanworker.timeout.html">GearmanWorker::timeout</a> — Get socket I/O activity timeout</li><li><a href="gearmanworker.unregister.html">GearmanWorker::unregister</a> — Unregister a function name with the job servers</li><li><a href="gearmanworker.unregisterall.html">GearmanWorker::unregisterAll</a> — Unregister all function names with the job servers</li><li><a href="gearmanworker.wait.html">GearmanWorker::wait</a> — Wait for activity from one of the job servers</li><li><a href="gearmanworker.work.html">GearmanWorker::work</a> — Wait for and perform jobs</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gearmantask.uuid.html">GearmanTask::uuid</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="gearmanworker.addfunction.html">GearmanWorker::addFunction</a></div>
 <div class="up"><a href="book.gearman.html">Gearman</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
